/*消息数小红点*/
import 'dart:ffi';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:frametrim/utility/TextUtils.dart';

class RedPointView extends StatelessWidget {
  late Widget child;
  late Color? redColor;
  late Color? TextColor;
  late double TextSize;
  late String TextStr;

  RedPointView(
      {required this.child,
      required this.TextStr,
      this.redColor = const Color(0xffE34D59),
      this.TextColor = const Color(0xffFFFFFF),
      this.TextSize = 13});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Center(
          child: child,
        ),
        Positioned(
          child: buildRedWeiget(context),
          right: 0,
          top: 0,
        )
      ],
    );
  }

/*小红点儿布局*/
  Widget buildRedWeiget(BuildContext context) {
    return Container(
      // width: TextUtils.calculateTextSize(context, TextStr, TextSize, FontWeight.normal, 100, 1).width+8,
      // padding: EdgeInsets.all(4),
     /* width: double.infinity,
      height: double.infinity,*/
      decoration: BoxDecoration(
        color: redColor,
        borderRadius: BorderRadius.all(Radius.circular(20)),
      ),
      child: Padding(

        padding: EdgeInsets.all(4),
        child: Text(
          TextStr,
          style: TextStyle(fontSize: TextSize, color: TextColor),
        ),
      ),
    );
  }
}
